package class_08;
/**
 *     阶乘问题
 * @author LOGAN
 *  	在阶乘问题中
 */
public class Code_01_Factorial {
	/**
	 * 非穷举
	 * @param n
	 * @return
	 */
	public static long getFactorial1(int n) {
		if (n == 1) {
			return 1L;
		}
		return (long) n * getFactorial1(n - 1);
	}

	/**
	 * 穷举类型
	 * @param n
	 * @return
	 */
	public static long getFactorial2(int n) {
		long result = 1L;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	}

	public static void main(String[] args) {
		int n = 5;
		System.out.println(getFactorial1(n));
		System.out.println(getFactorial2(n));
	}

}
